#include "guish.hpp"
#ifndef BUILTIN_HPP
#define BUILTIN_HPP

class DisabledBuiltin
	:public std::exception
	{ };

#define BUILTIN_ARGS (ExecutionEnvironment *execEnv, Job *job, const vector<string> &argv)

typedef int (*BuiltinFunc) BUILTIN_ARGS;
void addBuiltin(BuiltinFunc func, const char *name);
bool isBuiltin(string cmd);
bool builtinTakesAssignments(string cmd);
bool builtinDisablesFileExpansion(string cmd);
BuiltinFunc getBuiltin(string cmd);

/// To define a builtin function, use
///   BUILTIN(command_name)
///   {
///       //This is a BuiltinFunc, with Job *job and vector<string> &argv
///   }
#define BUILTIN(name, cmd) \
	int builtin_##name BUILTIN_ARGS; \
	void addBuiltin_##name() { addBuiltin(builtin_##name, cmd); } \
	StartupCaller addBuiltinCaller_##name(addBuiltin_##name); \
	int builtin_##name BUILTIN_ARGS

#endif
